<template>
	<view class="ikz-bid">
		<ikz-loading :css-data="loading_css"></ikz-loading>
		<view>
			<ikz-login :show-data="loginData" :css-data="login_css"></ikz-login>
		</view>
		<view class="ikz-ordertop">
			<view class="ikz-ordertop-top">
				<view class="ikz-order-top-title">
					我的订单
				</view>
				<view class="ikz-order-top-more" @click="myOrder('')">
					查看全部
				</view>
			</view>
			<view class="ikz-ordertop-list">
				<view class="ikz-ordertop-item" @click="myOrder(0)">
					<image class="ikz-ordertop-img" src="/static/supermarket/user/icon_order_pay.png"></image>
					<view class="ikz-ordertop-item-title">
						待付款
					</view>
					<view class="ikz-ordertop-item-num" v-if="number_info.not_pay_count">
						{{number_info.not_pay_count}}
					</view>
				</view>
				<view class="ikz-ordertop-item" @click="myOrder(1)">
					<image class="ikz-ordertop-img" src="/static/supermarket/user/icon_order_receive.png"></image>
					<view class="ikz-ordertop-item-title">
						待接单
					</view>
					<view class="ikz-ordertop-item-num" v-if="number_info.not_receive_count">
						{{number_info.not_receive_count}}
					</view>
				</view>
				<view class="ikz-ordertop-item" @click="myOrder(2)">
					<image class="ikz-ordertop-img" src="/static/supermarket/user/icon_order_wait.png"></image>
					<view class="ikz-ordertop-item-title">
						待确认
					</view>
					<view class="ikz-ordertop-item-num" v-if="number_info.not_confirm_count">
						{{number_info.not_confirm_count}}
					</view>
				</view>
				<view class="ikz-ordertop-item" @click="myOrder(3)">
					<image class="ikz-ordertop-img" src="/static/supermarket/user/icon_order_complete.png"></image>
					<view class="ikz-ordertop-item-title">
						已完成
					</view>
				</view>
			</view>
		</view>
		<view class="ikz-menu-box">
			<view class="ikz-menu-title">系统中心</view>
			<ikz-menu :show-data="menu_data" :css-data="menu_css"></ikz-menu>
		</view>
		<!-- 缺省 -->
		<view class="default-height" style="width: 100%;height: 92rpx;"></view>
		<ikz-tabbar :show-data="tabbar_Data"></ikz-tabbar>
	</view>
</template>

<script>
	import ikzLoading from '@/pages/Component/Public/Loading/loading.vue';
	import ikzMenu from '@/pages/Component/Public/Menu/public/menu5/menu.vue';
	import ikzLogin from '@/pages/Component/Public/Login/public/login/login.vue';
	import ikzTabbar from '@/pages/Component/Public/tab-bar/tab-bar.vue';
	var app = getApp();
	import ikz from '@/pages/Common/tools.js';
	export default {
		components: {
			ikzLoading,
			ikzMenu,
			ikzLogin,
			ikzTabbar
		},
		data() {
			return {
				tabbar_Data: {
					type: 1,
					list: [
						{
							title: "首页",
							url: "/pages/Component/supermarket/Program/index/index",
							iconPath: "/static/supermarket/tabbar/tab_home.png",
							selectedIconPath: "/static/supermarket/tabbar/tab_home_sel.png",
							status: 1,
						},
						{
							title: "我的",
							url: "/pages/Component/supermarket/Program/user/index",
							iconPath: "/static/supermarket/tabbar/tab_user.png",
							selectedIconPath: "/static/supermarket/tabbar/tab_user_sel.png",
							status: 1,
						},
					]
				},
				loginData: {},
				login_css: {
					background_color: 'linear-gradient(to right,#F8C66D, #FBAB7E)',
					margin_top: 0,
					bg_border_radius: 0,
					width: 100
				},
				loading_css: {
					display: 'flex'
				},
				menu_data: {
					list: [{
							src: '/static/supermarket/user/icon_tel.png',
							title: '商家入驻',
							url: {
								path: '',
								info: '无功能',
								mode: '5'
							}
						},
						{
							src: '/static/supermarket/user/icon_join.png',
							title: '合作加盟',
							url: {
								path: 'phone#' + app.globalData.customer_mobile,
								info: '无功能',
								mode: '5'
							}
						},
						{
							src: '/static/supermarket/user/icon_agreement.png',
							title: '用户协议',
							url: {
								path: '/pages/Component/Module/Other/Program/agreement/index',
								info: '无功能',
								mode: '2'
							}
						},
						{
							src: '/static/supermarket/user/icon_address.png',
							title: '地址管理',
							url: {
								path: '/pages/Component/Module/Address/Program/myAddress/index',
								info: 'token',
								mode: '2'
							}
						},
					]
				},
				menu_css: {
					background_color: '#fff',
					bg_border_radius: 0,
					border_radius: '0',
					color: '#888888',
					margin_top: 15,
					num: '4',
					width: 100,
					imgWidth: 72
				},
				number_info: {},
				run_apply_status: ''
			};
		},
		created() {
			// var that = this;
		},
		onLoad() {
			
		},
		onShow() {
			this.goApplyPhone()
			if(!uni.getStorageSync("user_info")) {
				this.loading_css.display = 'none';
				return
			}
			this.loginData.user_openinfo = uni.getStorageSync("user_info")
			this.loginData.mobile = app.globalData.mobile || ''
			this.orderNumber()
			this.userAuth((res) => {
				this.loading_css.display = 'none';
			});
		},
		onPullDownRefresh() {
			this.goApplyPhone()
			if(!uni.getStorageSync("user_info")) {
				this.loading_css.display = 'none';
				uni.stopPullDownRefresh();
				return
			}
			this.orderNumber()
			this.userAuth((res) => {
				uni.stopPullDownRefresh();
			});
		},
		onShareTimeline() {

		},
		onShareAppMessage() {
			return {
				title: app.globalData.share_info.share_title,
				path: '/pages/Component/supermarket/Program/user/index',
				imageUrl: app.globalData.share_info.share_img,
			}
		},
		methods: {
			// 获取订单菜单数量角标
			orderNumber() {
				var path = '/xyb/supermarket/order/center_order_count';
				var data = {}
				ikz.post(path, data, res => {
					if (res.data.code) {
						this.number_info = res.data.data;
						this.$forceUpdate();
					} else {
						uni.showModal({
							title: '提示',
							content: res.data.msg,
							showCancel: false,
							success: function(res) {}
						});
					}
				});
			},
			// 获取代理商手机号
			goApplyPhone() {
				var path = '/xyb/agent/phone';
				var data = {}
				ikz.post(path, data, res => {
					if (res.data.code) {
						this.menu_data.list[0].url.path = 'phone#' + res.data.data.phone,
							this.$forceUpdate();
					} else {
						uni.showModal({
							title: '提示',
							content: res.data.msg,
							showCancel: false,
							success: function(res) {}
						});
					}
				});
			},
			// 跳转详情
			myOrder(e) {
				if(!uni.getStorageSync("user_info")) {
					uni.navigateTo({
						url: "/pages/login/index"
					})
					return
				}
				uni.navigateTo({
					url: "/pages/Component/supermarket/Program/order/index?status="+e
				})
			},
			//请求页面数据
			userAuth(fn) {
				var path = '/xyb/user/auth';
				var data = {};
				ikz.post(path, data, res => {
					if (res.data.code) {
						
					} else {
						uni.showModal({
							title: '提示',
							content: res.data.msg,
							showCancel: false,
							success: function(res) {}
						});
					}
					fn();
					// if(that.pull_status){
					// 	this.$emit("change",'pull');
					// }
				});
			},
		}
	};
</script>

<style lang="scss" scoped>
	.ikz-bid {
		width: 100%;
		height: 100%;
		min-height: 100vh;
		background: #F3F3F3;
	}

	.ikz-menu-title {
		position: relative;
		box-sizing: border-box;
		width: 100%;
		padding: 0px 30rpx 10px 50rpx;
		font-weight: 800;
	}

	.ikz-menu-title:before {
		content: " ";
		display: inline-block;
		height: 40rpx;
		width: 10rpx;
		background: #FBAB7E;
		border-radius: 15rpx;
		position: absolute;
		left: 30rpx;
		top: 0px
	}

	.ikz-menu-box {
		box-sizing: border-box;
		padding: 30rpx 0px 30rpx;
		width: 95%;
		margin: 20rpx auto 0px;
		background: #fff;
		border-radius: 15rpx;
		overflow: hidden;
	}
	
	.ikz-ordertop {
		box-sizing: border-box;
		width: 95%;
		background: #fff;
		margin: 0 auto;
		border-radius: 15rpx;
		padding: 0 0 20rpx 0;
	}
	
	.ikz-ordertop-top {
		box-sizing: border-box;
		padding: 20rpx 40rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		line-height: 60rpx;
	}
	
	.ikz-order-top-title {
		font-weight: 800;
		font-size: 28rpx;
	}
	
	.ikz-order-top-more {
		font-size: 26rpx;
		color: #888;
	}
	
	.ikz-ordertop-list {
		width: 95%;
		margin: 0 auto;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	
	.ikz-ordertop-item {
		position: relative;
		wdith: 25%;
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		justify-content: center;
	}
	
	.ikz-ordertop-img {
		width: 90rpx;
		height: 90rpx;
	}
	
	.ikz-ordertop-item-title {
		width: 100%;
		text-align: center;
		font-size: 28rpx;
		line-height: 50rpx;
	}
	
	.ikz-ordertop-item-num {
		position: absolute;
		right: 30rpx;
		top: -10rpx;
		width: 40rpx;
		height: 40rpx;
		text-align: center;
		line-height: 40rpx;
		color: #fff;
		background: #FBAB7E;
		border-radius: 50%;
		font-size: 23rpx;
	}
</style>
